package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.financing.wap.common.BizEnums.CommonEnums;
import com.financing.wap.dao.IFpClientOrderDao;
import com.financing.wap.dto.FpClientOrderDTO;
import com.financing.wap.service.IFpClientOrderService;
import com.financing.wap.util.DTOdateSetUtil;
/**
 * fp_client_order  
 * 理财师店铺订单 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Repository("fpClientOrderService")
public class FpClientOrderServiceImpl implements IFpClientOrderService{

	@Autowired
	private IFpClientOrderDao fpClientOrderDao;

	@Override
	public int insert(FpClientOrderDTO fpClientOrder) throws SQLException {
		DTOdateSetUtil.setCreateInfo(fpClientOrder);
		DTOdateSetUtil.setUpdateInfo(fpClientOrder);
		fpClientOrder.setDeleteTag(CommonEnums.VALID_FLAG_1);
		return fpClientOrderDao.insert(fpClientOrder);
	}

	@Override
	public void update(FpClientOrderDTO fpClientOrder) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpClientOrder);
		fpClientOrderDao.update(fpClientOrder);
	}

	@Override
	public void updateForce(FpClientOrderDTO fpClientOrder) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpClientOrder);
		fpClientOrderDao.updateForce(fpClientOrder);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		fpClientOrderDao.delete(id);
	}
	
	@Override
	public List<FpClientOrderDTO> queryList(FpClientOrderDTO fpClientOrder) throws SQLException {
		return fpClientOrderDao.queryList(fpClientOrder);
	}

	@Override
	public int queryListCount(FpClientOrderDTO fpClientOrder) throws SQLException {
		return fpClientOrderDao.queryListCount(fpClientOrder);
	}

	@Override
	public FpClientOrderDTO loadById(Integer id) throws SQLException {
		return fpClientOrderDao.loadById(id);
	}
 	@Override
	public FpClientOrderDTO queryListGetFirst(FpClientOrderDTO fpClientOrder)
			throws SQLException {
		 List<FpClientOrderDTO> queryList = queryList(fpClientOrder);
		 if(queryList==null||queryList.size()==0){
			 return new FpClientOrderDTO();
		 }
		 return queryList.get(0);
	}
 	
	@Override
	public Double orderCont(FpClientOrderDTO fpClientOrder) throws SQLException {
		Double count = fpClientOrderDao.orderCont(fpClientOrder);
		return count;
	}
	@Override
	public Double orderContByUserId(FpClientOrderDTO fpClientOrder) throws SQLException {
		Double count = fpClientOrderDao.orderContByUserId(fpClientOrder);
		return count;
	}
	
	@Override
	public List<FpClientOrderDTO> queryListTimes(FpClientOrderDTO fpClientOrder) {
		List<FpClientOrderDTO> count = fpClientOrderDao.queryListTimes(fpClientOrder);
		return count;
	}
}
